package com.platform.qujia.enums;

import java.util.HashMap;

/**
 * @date 2023/12/10
 */
public enum PhysicalCardPaymentEnum {
    //xj:现金，pos:聚合支付，bka:后台增加，czkxf:实体-储值卡消费，dekxf:实体-定额卡消费，ref:充值退款
    XJ("xj","现金"),
    POS("pos","移动支付"),
    MANUAL_ADD("bka","后台增加"),
    WX("wx","微信支付"),

    STORED_CONSUMPTION("czkxf","储值卡消费"),
    RATION_CONSUMPTION("dekxf","定额卡消费"),
    REFUND("ref","充值退款"),
    ;

    private String value;
    private String text;

    PhysicalCardPaymentEnum(String value, String text) {
        this.value = value;
        this.text = text;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }


    private static HashMap<String, PhysicalCardPaymentEnum> keyMap;

    public static PhysicalCardPaymentEnum getByValue(String key){
        if (keyMap == null) {
            HashMap<String, PhysicalCardPaymentEnum> map = new HashMap<>();
            for (PhysicalCardPaymentEnum value : PhysicalCardPaymentEnum.values()) {
                map.put(value.getValue(),value);
            }
            keyMap = map;
        }
        return keyMap.get(key);
    }

    public static PhysicalCardPaymentEnum getByValue(String key,PhysicalCardPaymentEnum recordType){
        PhysicalCardPaymentEnum type = getByValue(key);
        return type == null ? recordType : type;
    }

}
